<?php
namespace app\admin\controller;
use think\facade\Request;
use think\Db;
class System extends Common
{
    /********************************站点管理*******************************/
    //站点设置
    public function system($sys_id=1){
        $table = db('system');
        if(Request::isAjax()) {
            $data = Request::except('file');
            $data['exchange_fee'] = intval($data['exchange_fee'])*100;
            $data['withdraw_fee'] = intval($data['withdraw_fee'])*100;
            if($table->where('id',1)->update($data)!==false) {
                savecache('System');
                return json(['code' => 1, 'msg' => '站点设置保存成功!', 'url' => url('system/system')]);
            } else {
                return json(array('code' => 0, 'msg' =>'站点设置保存失败！'));
            }
        }else{
            $system = $table->field('id,name,url,key,des,bah,copyright,ads,tel,email,exchange_fee,withdraw_fee')->find($sys_id);
            $system['exchange_fee'] = intval($system['exchange_fee'])/100;
            $system['withdraw_fee'] = intval($system['withdraw_fee'])/100;
            $this->assign('system', $system);
            return $this->fetch();
        }
    }

}
